﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Register.BLL;
using Register.Command;
using Register.DAL;
using Register.Model;
using System.Web.Script.Serialization;
namespace RegisterWeb.Manager.DoctorPersonalCenter.ashx
{
    /// <summary>
    /// DoctorPersonInfoHandler 的摘要说明
    /// </summary>
    public class DoctorPersonInfoHandler : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
           string action=context.Request["action"];
           #region 获取医生个人信息
           if (action.Equals("get")) {
              
               List<DoctorUserInfo> list = new List<DoctorUserInfo>();
               list = DoctorPersonInfoBLL.GetDoctorUserInfo("DU20120706002");  //临时模拟赋予一个医生用户ID
               List<DoctorPersonInfoJSON> json = new List<DoctorPersonInfoJSON>();
               foreach (DoctorUserInfo doc in list)
               {
                   List<DoctorInfo> list1 = new List<DoctorInfo>(); //医生用户
                   list1 = DoctorPersonInfoBLL.GetDoctorInfo(doc.Doctor_ID);
                    string DoctorUser_ID = doc.DoctorUser_ID;
                   string Doctor_ID = doc.Doctor_ID;
                   string DoctorUser_UserName = doc.DoctorUser_UserName;
                   string DoctorUser_Password = doc.DoctorUser_Password;
                   string DoctorUser_LastRegTime = Convert.ToString(doc.DoctorUser_LastRegTime);
                   foreach(DoctorInfo di in list1){
                       json.Add(new DoctorPersonInfoJSON(DoctorUser_ID, DoctorUserInfoBLL.GetDoctorNameById(Doctor_ID), DoctorUser_UserName, DoctorUser_Password, DoctorUser_LastRegTime, DoctorInfoBLL.GetDepartmentsNameById(Convert.ToString(di.Departments_ID)), Convert.ToString(di.Doctor_DateOfBirth).Substring(0,9), HospitalInfoBLL.GetParamNameById(Convert.ToString(di.Doctor_Education)), Convert.ToString(di.Doctor_Email), Convert.ToString(di.Doctor_Gender),Convert.ToString(di.Doctor_Name), Convert.ToString(di.Doctor_No), Convert.ToString(di.Doctor_Phone), Convert.ToString(di.Doctor_Picture),HospitalInfoBLL.GetParamNameById(Convert.ToString(di.Doctor_Position)), Convert.ToString(di.Doctor_Resume), Convert.ToString(di.Doctor_Specialty)));
                   }

                 //  json.Add(new DoctorUserInfoJSON(doc.DoctorUser_ID, DoctorUserInfoBLL.GetDoctorNameById(doc.Doctor_ID), doc.DoctorUser_UserName, doc.DoctorUser_Password, doc.DoctorUser_AddTime.ToString(), doc.DoctorUser_Recoder));
               }

               JavaScriptSerializer jss = new JavaScriptSerializer();
               context.Response.Write(jss.Serialize(json));

           }
           #endregion
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}

class DoctorPersonInfoJSON
{
    public string DoctorUser_ID
    {
        set;
        get;
    }
    public string Doctor_ID
    {
        set;
        get;
    }
    public string DoctorUser_UserName
    {
        get;
        set;
    }
    public string DoctorUser_Password
    {
        get;
        set;
    }

    public string DoctorUser_LastRegTime
    {
        get;
        set;
    }
  
    public string Departments_ID
    {
        get;
        set;
    }
    public string Doctor_DateOfBirth
    {
        get;
        set;
    }

    public string Doctor_Education
    {
        get;
        set;
    }
    public string Doctor_Email
    {
        get;
        set;
    }
    public string Doctor_Gender
    {
        get;
        set;
    }

    public string Doctor_Name
    {
        get;
        set;
    }

    public string Doctor_No
    {
        get;
        set;
    }

    public string Doctor_Phone
    {
        get;
        set;
    }

    public string Doctor_Picture
    {
        get;
        set;
    }

    public string Doctor_Position
    {
        get;
        set;
    }
  

  

    public string Doctor_Resume
    {
        get;
        set;
    }

    public string Doctor_Specialty
    {
        get;
        set;
    }




    public DoctorPersonInfoJSON(string DoctorUser_ID, string Doctor_ID, string DoctorUser_UserName, string DoctorUser_Password, string DoctorUser_LastRegTime, string Departments_ID, string Doctor_DateOfBirth, string Doctor_Education, string Doctor_Email, string Doctor_Gender, string Doctor_Name, string Doctor_No, string Doctor_Phone, string Doctor_Picture, string Doctor_Position, string Doctor_Resume, string Doctor_Specialty)
    {
        this.Departments_ID = Departments_ID;
        this.Doctor_DateOfBirth=Doctor_DateOfBirth;
        this.Doctor_Education=Doctor_Education;
        this.Doctor_Email = Doctor_Email; ;
        this.Doctor_Gender=Doctor_Gender;
        this.Doctor_ID = Doctor_ID;
        this.Doctor_Name = Doctor_Name;
        this.Doctor_ID = Doctor_ID;
        this.Doctor_Name = Doctor_Name;
        this.Doctor_No = Doctor_No;
        this.Doctor_Phone = Doctor_Phone;
        this.Doctor_Picture = Doctor_Picture;
        this.Doctor_Position = Doctor_Position;
        this.Doctor_Resume = Doctor_Resume;
        this.Doctor_Specialty = Doctor_Specialty;
        this.DoctorUser_ID = DoctorUser_ID;
        this.DoctorUser_LastRegTime = DoctorUser_LastRegTime;
        this.DoctorUser_Password = DoctorUser_Password;
        this.DoctorUser_UserName = DoctorUser_UserName;
        

    }

}
